<sel name="Public/content-base"/>
<extend name="Public/base" />

<block name="body">
	<script type="text/javascript" src="__STATIC__/mydatepicker.js"></script>
   
    <div class="main-title">
        <h2> {$name}-{:isset($info['id'])?'编辑':'新增'}内容</h2>
    </div>
    <form action="{:U()}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">广告名称<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="title" value="{$info.title|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">链接地址<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="url" value="{$info.url|default=''}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">广告图片：<span class="check-tips"></span></label>
            <div class="controls">
                <input type="file" id="upload_picture">
                <input type="hidden" name="icon" id="thumb" value="{$info.icon|default=''}"/>
                <div class="upload-img-box">
                    <notempty name="info.icon">
                        <div class="upload-pre-item">
                            <img src="__ROOT__{$info.icon|get_cover=###,'path'}" />
                        </div>
                    </notempty>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
                    <link rel="stylesheet" href="__STATIC__/uploadify/uploadify.css" />
                    <script type="text/javascript">
                        //上传图片
                        /* 初始化上传插件 */
                        $("#upload_picture").uploadify({
                            "height": 30,
                            "swf": "__STATIC__/uploadify/uploadify.swf",
                            "fileObjName": "download",
                            "buttonText": "上传图片",
                            "uploader": "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                            "width": 120,
                            'removeTimeout': 1,
                            'fileTypeExts': '*.jpg; *.png; *.gif;',
                            "onUploadSuccess": uploadPicture,
                            'onFallback': function() {
                                alert('未检测到兼容版本的Flash.');
                            }
                        });
                        function uploadPicture(file, data) {
                            var data = $.parseJSON(data);
                            var src = '';
                            if (data.status) {
                                $("#thumb").val(data.id);
                                src = data.url || '__ROOT__' + data.path;
                                $("#thumb").parent().find('.upload-img-box').html('<div class="upload-pre-item"><img src="' + src + '"/></div>');
                            } else {
                                updateAlert(data.info);
                                setTimeout(function() {
                                    $('#top-alert').find('button').click();
                                    $(that).removeClass('disabled').prop('disabled', false);
                                },
                                1500);
                            }
                        }
                    </script>       
        <div class="form-item">
            <label class="item-label">描述<span class="check-tips"></span></label>
            <div class="controls">
                <textarea name="description" class="span10">{$info.description}</textarea>
            </div>
        </div>
        <div class="form-item">
            <input type="hidden" name="id" value="{$info.id|default=''}">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>